using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using MoMing.VideoTool.Downloader.Infrastructure;
using MoMing.VideoTool.Downloader.Services;

namespace MoMing.VideoTool.Downloader.Extensions
{
    public static class Extensions
    {
        public static void AddApplicationServices(this IHostApplicationBuilder builder)
        {
            var services = builder.Services;
            services.AddDbContext<DonwloaderContext>(options =>
         {
             var s = builder.Configuration.GetConnectionString("VideoToolDB");
             options.UseNpgsql(s);
         });
            builder.EnrichNpgsqlDbContext<DonwloaderContext>();

            // REVIEW: This is done for development ease but shouldn't be here in production
            builder.Services.AddMigration<DonwloaderContext, DonwloaderContextSeed>();

            builder.Services.AddScoped<IDouYinService, DouYinService>();

        }


    }
}